package com.evil.activiti.cmd;

import lombok.AllArgsConstructor;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.Process;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;

/**
 * 获取Process
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@AllArgsConstructor
public class ProcessGetCmd implements Command<Process> {

    private final String processDefinitionId;

    @Override
    public Process execute(CommandContext commandContext) {
        BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
        return bpmnModel.getProcesses().get(0);
    }
}